import json
import pyperclip
import tkinter.filedialog
import tkinter.messagebox


def ask_load():
    path = tkinter.filedialog.askopenfilename()
    if path:
        return path
    exit(0)

def ask_save():
    path = tkinter.filedialog.asksaveasfilename()
    if path:
        return path
    exit(0)

def ask_files():
    paths = tkinter.filedialog.askopenfilenames()
    if len(paths) > 0:
        return paths
    exit(0)

def ask_dir():
    path = tkinter.filedialog.askdirectory()
    if path:
        return path
    exit(0)

def ask_continue2(title, info):
    if not tkinter.messagebox.askokcancel(title, info):
        exit(0)

def ask_continue3(title, info):
    res = tkinter.messagebox.askyesnocancel(title, info)
    if res is None:
        exit(0)
    return not res


def print_and_copy_clipboard(obj):
    data = json.dumps(obj, indent=4, ensure_ascii=False)
    pyperclip.copy(data)
    print(data)


